package com.glodon.paas.monitor.server.biz.service.impl;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.paas.monitor.server.biz.domain.MonitorItemEntity;
import com.glodon.paas.monitor.server.biz.mapper.MonitorItemMapper;
import com.glodon.paas.monitor.server.biz.service.MonitorItemService;
import com.glodon.paas.monitor.server.dto.MonitorItemDTO;
import com.glodon.paas.monitor.server.exception.MonitorException;

@Service("monitorItemService")
public class MonitorItemServiceImpl implements MonitorItemService {

	@Autowired
	private MonitorItemMapper	monitorItemMapper;

	@Override
	public int deleteByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "deleteByPrimaryKey Item id is null!");
		}
		return monitorItemMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MonitorItemEntity record) {
		if (null == record || null == record.getAppId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insert Item record is null!");
		}
		return monitorItemMapper.insert(record);
	}

	@Override
	public int insertSelective(MonitorItemEntity record) {
		if (null == record || null == record.getAppId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insertSelective Item record is null!");
		}
		return monitorItemMapper.insertSelective(record);
	}

	@Override
	public MonitorItemEntity selectByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "selectByPrimaryKey Item id is null!");
		}
		return monitorItemMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(MonitorItemEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKeySelective Item record is null!");
		}
		return monitorItemMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(MonitorItemEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKey Item record is null!");
		}
		return monitorItemMapper.updateByPrimaryKey(record);
	}

	@Override
	public ArrayList<MonitorItemDTO> queryMonitorItem(MonitorItemDTO record) {

		return monitorItemMapper.queryMonitorItem(record);
	}

}
